/*
 * @lc app=leetcode.cn id=14 lang=javascript
 *
 * [14] 最长公共前缀
 */

// @lc code=start
/**
 * @param {string[]} strs
 * @return {string}
 */
var longestCommonPrefix = function(strs) {
  let maxStr = strs[0]
  for (let i = 1; i < strs.length; i++) {
    let point = 0
    while (point < strs[i].length && point < maxStr.length) {
      if (!(maxStr[point] === strs[i][point])) break
      point++
    }
    if (!point) return ''
    maxStr = maxStr.slice(0, point)
  }
  return maxStr
};
// @lc code=end

